import request from "@/utils/request"


// 添加员工
export function addEmployeeApi(addEmployeeDto) {
    return request({
        url: '/employee/save',
        method: 'post',
        data: addEmployeeDto
    });
}

// 删除员工
export function deleteEmployeeApi(id) {
    return request({
        url: `/employee/delete/${id}`,
        method: 'delete'
    });
}

// 更新员工
export function updateEmployeeApi(employeeDto) {
    return request({
        url: '/employee/update',
        method: 'post',
        data: employeeDto
    });
}

// 根据ID获取员工
export function getEmployeeByIdApi(id) {
    return request({
        url: `/employee/info/${id}`,
        method: 'get'
    });
}

// 分页查询员工列表
export function pageListEmployeeApi(pageNum, pageSize,searchKeyword,companyId) {
    return request({
        url: '/employee/query-page',
        method: 'post',
        data: {
            "pageNum": pageNum ,
            "pageSize": pageSize,
            "searchKeyword": searchKeyword,
            "companyId":companyId
        }
    });
}

// 导出员工
export function exportEmployeesApi(searchKeyword, companyId) {
    return request({
        url: '/employee/export',
        method: 'post',
        data:{
            "searchKeyword": searchKeyword,
            "companyId":companyId
        },
        // 响应类型为二进制流
        responseType: 'blob',
    })
}

// 导入员工
export function importEmployeesApi(formData) {
    return request({
        url: '/employee/import',
        method: 'post',
        data: formData,
        // 上传文件需要设置Content-Type为multipart/form-data
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        responseType: 'blob'
    })
}
